﻿@{
    ViewBag.Title = "FuncDemo";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<script src="/JsLib/G_Math.js?201306131500" type="text/javascript"></script>

<script type="text/javascript">
    
    var book = {
        "title": "Javascript Definitive Guide",
        "publish date": "2009-05-08",
        author: {
            firstname: "David",
            lastname: "Flanagan"
        }
    };

    window.onload = function () {
        /*
            Print properties
         */

        ZEUS.DEBUG.log("1. ** print properties **");
        ObjUtil.printProperties(book);

        ZEUS.DEBUG.log("<br />");

        /*
            Math Functions
         */

        ZEUS.DEBUG.log("2. ** math functions **");
        var distantce = MathUtil.getCordDistance(2, 3, 5, 8);
        ZEUS.DEBUG.log("distantce between (2, 3) <--> (5, 8): " + distantce);
        ZEUS.DEBUG.log("factorial of 5: " + MathUtil.factorial(5));
        var op1 = 8;
        var op2 = 2;
        ZEUS.DEBUG.log(op1 + " + " + op2 + " = " + Operator.add(op1, op2));
        ZEUS.DEBUG.log(op1 + " - " + op2 + " = " + Operator.subtract(op1, op2));
        ZEUS.DEBUG.log(op1 + " * " + op2 + " = " + Operator.multiply(op1, op2));
        ZEUS.DEBUG.log(op1 + " / " + op2 + " = " + Operator.divide(op1, op2));

        ZEUS.DEBUG.log("<br />");

        /*
            Mutable Length Arguments
         */

        ZEUS.DEBUG.log("3. ** mutable length arguments **");
        var num = MathUtil.max(100, 23, 109, 88.8, 128.8);
        ZEUS.DEBUG.log("Max Value in (100, 23, 109, 88.8, 128.8): " + num);
        num = MathUtil.min(100, 23, 109, 88.8, 128.8);
        ZEUS.DEBUG.log("Min Value in (100, 23, 109, 88.8, 128.8): " + num);

        ZEUS.DEBUG.log("<br />");

        /*
            judge function 
         */

        ZEUS.DEBUG.log("4. ** judge function **");
        ZEUS.DEBUG.log("book.title is function? " + ObjUtil.isFunction(book.title));
        ZEUS.DEBUG.log("book.author is function? " + ObjUtil.isFunction(book.author));
        ZEUS.DEBUG.log("MathUtil is function? " + ObjUtil.isFunction(MathUtil));
        ZEUS.DEBUG.log("MathUtil.min is function? " + ObjUtil.isFunction(MathUtil.min));

        ZEUS.DEBUG.log("<br />");

        /*
            judge function 
         */

        ZEUS.DEBUG.log("5. ** max common divisor **");
        ZEUS.DEBUG.log("max common divisor between 16 and 24: " + MathUtil.maxCommonDivisor(16, 24));

        ZEUS.DEBUG.log("<br />");
    }

</script>


<h2>Function Demo</h2>
<br />
<h3>Path: @ViewBag.Path</h3>
<br />
<h3>Extended JS: /JsLib/G_Core.js, G_Math.js</h3>
<br />
<h3>See the result on console</h3>
<br />


